import sys, os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

import time
from flask import request


def log_request():
    """记录请求日志的中间件"""
    request.start_time = time.time()
    print(f"[{request.method}] {request.path} - Received")


def format_response(data):
    """标准化的响应格式"""
    return {
        "success": True,
        "data": data,
        "timestamp": int(time.time())
    }
